using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

using System.Windows.Controls.Primitives;


namespace App3._2
{
    /// <summary>
    /// Interaction logic for Window1.xaml
    /// </summary>

    public partial class Window1 : System.Windows.Window
    {
        public Window1()
        {
            InitializeComponent();

            ToggleButton toggleButton = new ToggleButton();
            toggleButton.IsThreeState = true;
            toggleButton.IsChecked = null;
            toggleButton.Checked += new RoutedEventHandler(OnChecked);
            toggleButton.Unchecked += new RoutedEventHandler(OnUnChecked);
            toggleButton.Indeterminate += new RoutedEventHandler(OnIndeterminate);
            toggleButton.Content = "Button2";
            stackPanel.Children.Add(toggleButton);
        }

        public void OnChecked(object sender, RoutedEventArgs args)
        {
            MessageBox.Show("Checked!");
        }

        public void OnUnChecked(object sender, RoutedEventArgs args)
        {
            MessageBox.Show("UnChecked!");
        }

        public void OnIndeterminate(object sender, RoutedEventArgs args)
        {
            MessageBox.Show("Indeterminate!");
        }
    }
}